package edu.mse.camel.client.whiteboard.gef.ui.editpart;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;

import edu.mse.camel.client.whiteboard.gef.ui.commands.FreeWritingShapeDeleteCommand;
import edu.mse.camel.client.whiteboard.gef.whiteboard.FreeWritingShape;
import edu.mse.camel.client.whiteboard.gef.whiteboard.WhiteboardDiagram;


class FreeWritingShapeComponentEditPolicy extends ComponentEditPolicy {
	
	/* (non-Javadoc)
	 * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
	 */


protected Command createDeleteCommand(GroupRequest deleteRequest) {
	Object parent = getHost().getParent().getModel();
	Object child = getHost().getModel();
	if (parent instanceof WhiteboardDiagram && child instanceof FreeWritingShape) {
        return new FreeWritingShapeDeleteCommand((WhiteboardDiagram) parent, (FreeWritingShape) child);
    }
	return super.createDeleteCommand(deleteRequest);
}
}